package com.autonavi.collapse.task.pipe.reader.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SimpleConnectionFactory implements ConnectionFactory {

    private static final String MYSQL_JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
    private String name;
    private String url;
    private String username;
    private String password;

    public SimpleConnectionFactory(String name, String url, String username, String password) {
        this.name = name;
        this.url = url;
        this.username = username;
        this.password = password;
    }

    public SimpleConnectionFactory(String name, String url, String username, String password, String driverClassName) throws ClassNotFoundException {
        this.name = name;
        this.url = url;
        this.username = username;
        this.password = password;
        Class.forName(driverClassName);
    }

    @Override
    public Connection getConnecttion() throws SQLException {
        return DriverManager.getConnection(url, username, password);
    }

    @Override
    public String getName() {
        return name;
    }
}
